﻿using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using NP.BPMReportPlatform.Entities.BPM_Business;
using NP.BPMReportPlatform.Entities.BPM_Business.LCZX;
using NP.BPMReportPlatform.MaterialMasterData;
using NP.BPMReportPlatform.MaterialMasterData.Dto;
using NP.BPMReportPlatform.MaterialMasterData.Dtos;
using Volo.Abp.Application.Dtos;

namespace NP.BPMReportPlatform.LCZXRZXQGL
{
    /// <summary>
    /// 立才认证配置表保存逻辑
    /// </summary>
    [Authorize]
    [ApiController]
    [Route("api/LCZXRZXQGL")]
    public class LCZXRZXQGLController : BPMReportPlatformController
    {
        private readonly ILCZXRZXQGLService _service;


        public LCZXRZXQGLController(ILCZXRZXQGLService service)
        {
            _service = service;
        }

        [HttpPost("list")]
        public async Task<List<LCZXRZXQGLConfigInputDto>> GetList([FromBody] LCZXRZXQGLConfigInputDto input)
        {
            return await _service.GetConfig(input);
        }

        [HttpPost("insert")]
        public async Task Insert([FromBody] LCZXRZXQGLConfigInputDto dto)
        {
            await _service.InsertConfig(dto);
        }


        [HttpPost("update")]
        public async Task Update([FromBody] LCZXRZXQGLConfigInputDto dto)
        {
            await _service.UpdateConfig(dto);
        }

        [HttpPost("delete/{id}")]
        public async Task Delete([FromRoute] Guid id)
        {
            await _service.DeleteConfig(id);
        }

        #region 配置子表
        [HttpGet("ChildList")]
        public async Task<PagedResultDto<LCZXRZXQGLConfigChild>> GetChildList(Guid configId, int PageIndex = 1, int PageSize = 10)
        {
            return await _service.GetChildConfigs(configId, PageIndex, PageSize);
        }
        [HttpPost("EditChild")]
        public async Task EditChild(LCZXRZXQGLConfigChild model)
        {
            await _service.EditChildConfig(model);
        }
        [HttpDelete("DeleteChild/{id}")]
        public async Task DeleteChild([FromRoute] Guid id)
        {
            await _service.DeleteChildConfig(id);
        }
        #endregion

        #region 证书数据维护

        /// <summary>
        /// 证书数据维护 查询数据
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        [HttpPost("GetCertificateData")]
        public async Task<PagedResultDto<LCZXRZXQGLDetail>> GetCertificateData([FromBody] GetCertificateDataInput input)
        {
            return await _service.GetCertificateData(input);
        }

        /// <summary>
        /// 证书数据维护 修改数据
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        [HttpPost("UpdateCertificateData")]
        public async Task<string> UpdateCertificateData([FromBody] UpdateCertificateDataInput input)
        {
            return await _service.UpdateCertificateData(input);
        }

        #endregion
    }
}